<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/mui.picker.min.css" />
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<style>
			span{float:left; padding:0 5px;}
			.mui-query-admin ul li span{ float: left; width:80px; text-align: right; line-height: 38px;}
			.mui-table-view .mui-media-object{height:58px; width:80px;}
			.mui-table-view{background:none;}
			.bottom{
				width: 100%;
				height: 50px;
				margin-top: 10px;
				padding: 5px 0;
				bottom: 0px;
				position: fixed;
				background-color: #fff;
			}
			#buttonu{
				width: 45%;
				margin: 0 0.5rem;
				height: 40px;
				float: left;
				line-height: 40px;
				text-align: center;
				background-color: #007AFF;
				border-radius: 10px;
				color: #FFFFFF;
				float: left;
				}
			#buttond{
				width: 45%;
				margin: 0 0.5rem;
				height: 40px;
				float: left;
				line-height: 40px;
				text-align: center;
				background-color: #007AFF;
				border-radius: 10px;
				color: #FFFFFF;
				float: right;
				}
			.mui-table-view-cell{padding:15px;}
			.mui-media{margin-top:10px; background-color: #fff;}
			.mui-media-body{float: left; width: 70%;}
			.mui-media-body ul{float: left; list-style: none; padding: 0; width: 70%;}
			.mui-media-body ul li{float: left;}
			.mui-media-body ul li b{margin-right: 20px; color: #007aff; line-height: 32px; font-size: 16px; font-family: "微软雅黑";}
			.mui-media-body ul li a1{margin-right: 20px; color: #000000; line-height: 32px; font-size: 16px; font-family: "微软雅黑";}
			.mui-ellipsis{color: #999999; margin-right: 10px; line-height: 32px; font-size: 16px; font-family: "微软雅黑";}
			.mui-pull-left{width: 60px; height: 60px; margin-right: 10px; border-radius: 30px;}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="list_id">查询列表</h1>
		</header>
		<div class="mui-conten mui-query-admin" style="margin-top:55px; padding-bottom: 55px; overflow-y: hidden;">
			<ul class="mui-table-view" id="patlist">
				
			</ul>
		</div>
		<div class="bottom" id="botdown">
			<div id="buttonu" onclick="upage()">上一页</div>
			<div id="buttond" onclick="dpage()">下一页</div>
		</div>
		<script src="../js/mui.js"></script>
		<script src="../js/jquery.min-1.11.1.js"></script>
		<script src="../js/request.js"></script>
		<script type="text/javascript">
			mui.init();
			var hospId = "";
			var regionId = "";
			var idCard = "";
			var nhCode = "";
			var patname = "";
			var pageIndex = "";
			var pageSize = "";
			var total = "";
			var patage = "";
			var rows = new Array;
			var headname = "";
			var queryType = "";
			var num = "";
			mui.plusReady(function(){
				var self = plus.webview.currentWebview()
					headname = self.name
					console.log(headname);
				console.log(JSON.stringify(self))
					if(headname == "高血压"){
						queryType = 1;
					}else if(headname == "糖尿病"){
						queryType = 2;
					}else if(headname == "肺结核"){
						queryType = 3;
					}else if(headname == "老年人"){
						queryType = 4;
					}else if(headname == "精神病"){
						queryType = 5;
					}else if(headname == "孕产妇"){
						queryType = 6;
					}else if(headname == "儿童健康"){
						queryType = 7;
					}
					hospId = self.hospId;
					regionId = self.regionId;
					idCard = self.idCard;
					nhCode = self.nhCode;
					patname = self.patname;
					pageIndex = self.pageIndex;
					pageSize = self.pageSize;
					num = Number(pageIndex)
				$.ajax({
					type: 'post',
 					url:getRequestUrl.url+"/mobile/IntegratedQuery/getEhrInfo",
 					data:{
 							hosp_id: hospId,
 							region_id: regionId,
							queryType: queryType,
 							id_card: idCard,
 							nh_code: nhCode,
 							name: patname,
 							page_index: pageIndex,
 							page_size: pageSize
 						},
 					dataType:"json",
 					success : function(data) {
						rows = data.rows;
						total = data.total/pageSize;
						var listcont = "";
						if(num <= 1){
							$("#buttonu").hide();
						}else{
							$("#buttonu").show();
						}
						if(rows.length < pageSize || total <= 1){
							$("#buttond").hide();
							$("#botdown").hide();
						}else{
							$("#buttond").show();
							$("#botdown").show();
						}
 						if(data.status==1){
							for(var i=0; i<rows.length; i++){
							var date0 = new Date(rows[i].birthday);
							var date1 = new Date();
							var year0=date0.getFullYear(); 
							var year1=date1.getFullYear(); 
								patage = year1-year0;
								listcont += '<li class="mui-table-view-cell mui-media">'
										+'<a onclick="lista('+i+')" href="javascript:;">'
										+'<img id="Pat_img'+i+'" class="mui-pull-left" src="../images/Patient-m.png">'
										+'<div class="mui-media-body">'
										+'<ul>'
										+'<li><b>'+rows[i].name+'</b><a1>性别:'+rows[i].sex+'</a1><a1>年龄:'+patage+'</a1></li>'
										+'<li><a2 class="mui-ellipsis">身份证:</a2><a1>'+rows[i].idCard+'</a1></li>'
										+'<li><a2 class="mui-ellipsis">医保号:</a2><a1>'+rows[i].nhCode+'</a1></li>'
										+'</ul>'
										+'</div>'
										+'</a>'
										+'</li>';
							}
 						}else{
 							//alert("空")
 						}
						$("#patlist").append(listcont);
						for(var j=0;j<rows.length; j++){
							//头像性别
							if(rows[j].sex == "女"){
								$("#Pat_img"+j).attr("src", "../images/Patient-w.png");
							}else{
								$("#Pat_img"+j).attr("src", "../images/Patient-m.png");
							}
						}
 					}
 				})
			})
			function upage(){
				$("#patlist").html("");
				num--;
				console.log(num)
				$.ajax({
					type: 'post',
					url:getRequestUrl.url+"/mobile/IntegratedQuery/getEhrInfo",
					data:{
							hosp_id: hospId,
							region_id: regionId,
							id_card: idCard,
							nh_code: nhCode,
							name: patname,
							page_index: num,
							page_size: pageSize
						},
					dataType:"json",
					success : function(data) {
						rows = data.rows;
						var listcont = "";
						if(num <= 1){
							$("#buttonu").hide();
						}else{
							$("#buttonu").show();
						}
						if(rows.length < pageSize || total <= num){
							$("#buttond").hide();
						}else{
							$("#buttond").show();
						}
						if(data.status==1){
							for(var i=0; i<rows.length; i++){
							var date0 = new Date(rows[i].birthday);
							var date1 = new Date();
							var year0=date0.getFullYear(); 
							var year1=date1.getFullYear(); 
								patage = year1-year0;
								listcont += '<li class="mui-table-view-cell mui-media">'
										+'<a onclick="lista('+i+')" href="javascript:;">'
										+'<img id="Pat_img'+i+'" class="mui-pull-left" src="../images/Patient-m.png">'
										+'<div class="mui-media-body">'
										+'<ul>'
										+'<li><b>'+rows[i].name+'</b><a1>性别:'+rows[i].sex+'</a1><a1>年龄:'+patage+'</a1></li>'
										+'<li><a2 class="mui-ellipsis">身份证:</a2><a1>'+rows[i].idCard+'</a1></li>'
										+'<li><a2 class="mui-ellipsis">医保号:</a2><a1>'+rows[i].nhCode+'</a1></li>'
										+'</ul>'
										+'</div>'
										+'</a>'
										+'</li>';
							}
						}else{
							
						}
						$("#patlist").append(listcont);
						for(var j=0;j<rows.length; j++){
							//头像性别
							if(rows[j].sex == "女"){
								$("#Pat_img"+j).attr("src", "../images/Patient-w.png");
							}else{
								$("#Pat_img"+j).attr("src", "../images/Patient-m.png");
							}
						}
					}
				})
			}
			function dpage(){
				$("#patlist").html("");
				num++;
				console.log(num)
				$.ajax({
					type: 'post',
					url:getRequestUrl.url+"/mobile/IntegratedQuery/getEhrInfo",
					data:{
							hosp_id: hospId,
							region_id: regionId,
							id_card: idCard,
							nh_code: nhCode,
							name: patname,
							page_index: num,
							page_size: pageSize
						},
					dataType:"json",
					success : function(data) {
						rows = data.rows;
						var listcont = "";
						if(num <= 1){
							$("#buttonu").hide();
						}else{
							$("#buttonu").show();
						}
						if(rows.length < pageSize || total <= num){
							$("#buttond").hide();
						}else{
							$("#buttond").show();
						}
						if(data.status==1){
							for(var i=0; i<rows.length; i++){

							var date0 = new Date(rows[i].birthday);
							var date1 = new Date();
							var year0=date0.getFullYear(); 
							var year1=date1.getFullYear(); 
								patage = year1-year0;
								listcont += '<li class="mui-table-view-cell mui-media">'
										+'<a onclick="lista('+i+')" href="javascript:;">'
										+'<img id="Pat_img'+i+'" class="mui-pull-left" src="../images/Patient-m.png">'
										+'<div class="mui-media-body">'
										+'<ul>'
										+'<li><b>'+rows[i].name+'</b><a1>性别:'+rows[i].sex+'</a1><a1>年龄:'+patage+'</a1></li>'
										+'<li><a2 class="mui-ellipsis">身份证:</a2><a1>'+rows[i].idCard+'</a1></li>'
										+'<li><a2 class="mui-ellipsis">医保号:</a2><a1>'+rows[i].nhCode+'</a1></li>'
										+'</ul>'
										+'</div>'
										+'</a>'
										+'</li>';
							}
						}else{
							
						}
						$("#patlist").append(listcont);
						for(var j=0;j<rows.length; j++){
							//头像性别
							if(rows[j].sex == "女"){
								$("#Pat_img"+j).attr("src", "../images/Patient-w.png");
							}else{
								$("#Pat_img"+j).attr("src", "../images/Patient-m.png");
							}
						}
					}
				})
			}
			var i;
			function lista(i){
				var listname = headname;
				var listdata = JSON.stringify(rows[i])
				mui.openWindow({
					url: 'follow_up.html', 
					id:'follow_up',
					extras:{
						name:listname,
						data:listdata
					}
				});
			}
			function establish(i,data){
				if(data == ""){
					var btnArray = ['否', '是'];
					mui.confirm('是否创建新档案？', btnArray, function(e) {
						if(e.index == 0){
							var listname = headname;
							var listdata = JSON.stringify(rows[i])
							mui.openWindow({
								url: 'info/info.html', 
								id:'info',
								extras:{
									name:listname,
									data:listdata
								}
							});
						} else {
							console.log(1)
						}
					})
				}else{
					var listname = headname;
					var listdata = JSON.stringify(rows[i])
					mui.openWindow({
						url: 'info/info.html', 
						id:'info',
						extras:{
							name:listname,
							data:listdata
						}
					});
				}
			}
		</script>
	</body>
</html>
